package truedano.merryme;

import com.example.test.R;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.app.Activity;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

public class MerryMe extends Activity {
	ImageView show_image_view;
	TextView show_text;
	
	int[] picList = {R.drawable.p001,R.drawable.p002,R.drawable.p003};
	int play_now = 0;
	
	@Override
	protected void onResume() {
		super.onResume();
		
		startCountDownTimer(picList.length*3,2);
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		setView();
		
	}
	
	private void setView(){
		show_image_view = (ImageView)findViewById(R.id.show_image_view);
		show_text = (TextView)findViewById(R.id.show_text);
	}
	
	private void startCountDownTimer(int sec,int wait){
		new CountDownTimer(sec*1000,wait*1000) {
			
			@Override
			public void onTick(long millisUntilFinished) {
				Log.i("truedano","onTick : play_now="+play_now+",picList.length="+picList.length);
				
				if( (play_now+1) == picList.length )
					play_now = 0;
				
				show_image_view.setImageResource(picList[play_now]);
				show_text.setText(""+play_now);
				play_now++;
			}
			
			@Override
			public void onFinish() {
				Log.i("truedano","onFinish : ");
			}
		}.start();
	}
}
